package org.zfes.snowier.zbss.xzy.router.user;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.common.websocket.WebsocketMsgHandler;
import org.zfes.snowier.core.data.JSONMSG;
import org.zfes.snowier.web.controller.BaseController;

import io.swagger.annotations.ApiOperation;
@Controller("org.zfes.snowier.zbss.xzy.router.user.WebsocketTest") 
@RequestMapping("/api/user/ws")
public class WebsocketTest implements BaseController {

	@Autowired
	WebsocketMsgHandler websocketMsgHandler;
	
	 @ApiOperation(value = "websocket消息发送")
	 @RequestMapping(value="/send", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	 public  @ResponseBody Object send(String  warnmsg){
	    
		websocketMsgHandler.sendToUser("1",new JSONMSG(200).setWsfun("wsfun").put("warnmsg", warnmsg) );
		  
		 return ajaxSuccess();
	  }
}
